﻿// 数字分数面板窗口 ScorePanel

#include "scorepanel.h"
#include "ui_scorepanel.h"

const QString MYCOLOR[] = { "black", "white", "red", "blue", "green" };
ScorePanel::ScorePanel(QWidget* parent) : QWidget(parent), ui(new Ui::ScorePanelClass)
{
	ui->setupUi(this);
	
	// 将ui界面的所有元素放进列表中，便于之后的操作
	m_list << ui->meScore << ui->leftScore << ui-> topScore << ui->rightScore
		<< ui->meTitle << ui->leftTitle << ui-> topScore << ui->rightTitle
		<< ui->score1 << ui->score2 << ui->score3 << ui->score4;
}

ScorePanel::~ScorePanel()
{
	delete ui;
}

// 将实际分数显示出来
void ScorePanel::setScores(int left, int right, int user, int top)
{
	ui->leftScore->setText(QString::number(left));
	ui->rightScore->setText(QString::number(right));
	ui->meScore->setText(QString::number(user));
	ui->topScore->setText(QString::number(top));
}

// 设置文字的字体
void ScorePanel::setMyFontSize(int point)
{
	QFont font("微软雅黑", point, QFont::Bold);
	for (int i = 0; i < m_list.size(); ++i)
	{
		m_list[i]->setFont(font);
	}
}

// 设置这个字体的颜色
void ScorePanel::setMyFontColor(FontColor color)
{
	QString style = QString("QLabel{color:%1}").arg(MYCOLOR[color]);
	for (int i = 0; i < m_list.size(); ++i)
	{
		m_list[i]->setStyleSheet(style);
	}
}
